package com.imcrl.geom
{
	import flash.geom.Rectangle;
	
	/**
	 *  模拟css样式表中的内填充
	 * 
	 * @author crl
	 * 
	 */	
	public class Padding
	{
		public static var EMPTY:Padding = new Padding(0, 0, 0, 0);
		
		public var bottom:Number;
		
		public var left:Number;
		
		public var right:Number;
		
		public var top:Number;
		
		/**
		 * 与css样式表一样,从12点钟方向顺时针赋值;
		 * @param top  上
		 * @param right 右
		 * @param bottom 下
		 * @param left 左
		 * 
		 */		
		public function Padding(top:int = 0, right:int = 0, bottom:int =int.MAX_VALUE, left:int = int.MAX_VALUE)
		{
			if(bottom==int.MAX_VALUE){
				bottom=top;
			}
			
			if(left==int.MAX_VALUE){
				left=right;
			}
			
			this.left = left;
			this.top = top;
			this.right = right;
			this.bottom = bottom;
		}
		
		public function getScale9Grid(width:int,height:int):Rectangle{
			var w:int=width-left-right;
			var h:int=height-top-bottom;
			return new Rectangle(left,top,w,h);
		}
		
	}
}